<!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">-->

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <!--<meta name="csrf-token" content="{{ csrf_token() }}" />-->
    <meta http-equiv="expires" content="0"> 
	<title>登录界面</title>
    <link href="/home/css/css/default.css" rel="stylesheet" type="text/css" />
	<!--必要样式-->
    <link href="/home/css/css/styles.css" rel="stylesheet" type="text/css" />
    <link href="/home/css/css/demo.css" rel="stylesheet" type="text/css" />
    <link href="/home/css/css/loaders.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="/admin/lib/layer/2.4/layer.js"></script>
</head>
<body>
	<div class='login'>
	<form action="" method="post" id="formElem">
	  <div class='login_title'>
	    <span> 用 户 登 录 </span>
	  </div>
	  <div class='login_fields'>
	    <div class='login_fields__user'>
	      <div class='icon'>
	        <img alt="" src='/home/images/img/user_icon_copy.png'>
	      </div>
	      <input name="username" placeholder='用户名' maxlength="16" type='text' autocomplete="off" value=""/>
	        <div class='validation'>
	          <img alt="" src='/home/images/img/tick.png'>
	        </div>
	    </div>
	    <div class='login_fields__password'>
	      <div class='icon'>
	        <img alt="" src="/home/images/img/lock_icon_copy.png">
	      </div>
	      <input name="password" placeholder='密码' maxlength="16" type='text' autocomplete="off">
	      <div class='validation'>
	        <img alt="" src='/home/images/img/tick.png'>
	      </div>
	    </div>
	    <div class='login_fields__password'>
	      <div class='icon'>
	        <img alt="" src='/home/images/img/key.png'>
	      </div>
	      <input name="code" placeholder='验证码' maxlength="4" type='text' name="ValidateNum" autocomplete="off">
	      <div class='validation' style="opacity: 1; right: -5px;top: -3px;">
          <canvas class="J_codeimg" id="myCanvas" onclick="Code();">对不起，您的浏览器不支持canvas，请下载最新版浏览器!</canvas>
	      </div>
	    </div>
		{{csrf_field()}}
	    <div class='login_fields__submit'>
	      <!--<input type='submit' value='登录' class="btnl">-->
	      <input type="button" value="提交" class="btnl" />
	    </div>
	  </div>
	  </form>
	  <div class='success'>
	  </div>
	  <div class='disclaimer'>
	    <p>没有账号？&nbsp;&nbsp;&nbsp;&nbsp;欢迎&nbsp;<a href="/home/member/index" style="text-decoration:none;color: #e1e1e1;font-weight:bold;">注册</a></p>
	  </div>
	  
	</div>
	<div class='authent'>
	  <div class="loader" style="height: 44px;width: 44px;margin-left: 28px;">
        <div class="loader-inner ball-clip-rotate-multiple">
            <div></div>
            <div></div>
            <div></div>
        </div>
        </div>
	  <p>认证中...</p>
	</div>
	<div class="OverWindows"></div>
    <link href="/home/layui/css/layui.css" rel="stylesheet" type="text/css" />
	<script src="/home/js/js/jquery-2.1.1.min.js"></script>
	<script type="text/javascript" src="/home/js/js/jquery-ui.min.js"></script>
	<script type="text/javascript" src='/home/js/js/stopExecutionOnTimeout.js?t=1'></script>
    <script src="/home/layui/layui.js" type="text/javascript"></script>
    <script src="/home/js/js/Particleground.js" type="text/javascript"></script>
    <script src="/home/js/js/Treatment.js" type="text/javascript"></script>
    <script src="/home/js/js/jquery.mockjax.js" type="text/javascript"></script>
    <!--validate 表单传值-->
    <!--<script src="http://static.runoob.com/assets/jquery-validation-1.14.0/dist/jquery.validate.min.js"></script>
    <script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/validate-methods.js"></script>
    <script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/messages_zh.js"></script>-->
    
    
	<script type="text/javascript">
		
		

		/*$("#formElem").validate({
	      onkeyup: false,
	     focusCleanup: true,
	      success: "valid",
	     submitHandler: function(form) {
	          $.ajax({
	             type: "post",  
	            url: "",  
	             contentType : "application/x-www-form-urlencoded; charset=UTF-8",  
	            data: { books: JSON.stringify(data), txtPass: "123" },  
	             success: function (res) {  
	                 alert('hello world');
	                 //alert(res);  
	                 //layer.close(ii);  
	             }  
	            })
        }

   		 });*/

		var canGetCookie = 0;//是否支持存储Cookie 0 不支持 1 支持
		var ajaxmockjax = 1;//是否启用虚拟Ajax的请求响 0 不启用  1 启用
		//默认账号密码


		var truelogin;
		var truepwd;
		$('.btnl').click(function (e) {
			
			username = $('input[name=username]').val();
			password = $('input[name=password]').val();
			
			$.ajax({
				headers: { 'X-CSRF-TOKEN' : '{{ csrf_token() }}' },
				url:'/home/member/memLogin',
				type:'post',
				async:false, 
				data:{username:username,password:password},
				success:function(data) {
					if(data == '1') {
						
						console.log('111');
						truelogin = "kbcxy";
						truepwd = "mcwjs";
//						alert(truelogin);				
//						alert(truepwd);				
//						truelogin = truepwd2;
//						truepwd = truepwd2;
					}else {
						console.log('222');
					}
				}
				
			});
			
			e.preventDefault();

		});		

//		truelogin = "kbcxy";
//		truepwd = "mcwjs";
		
		
		var CodeVal = 0;
	    Code();
	    function Code() {
			if(canGetCookie == 1){
				createCode("AdminCode");
				var AdminCode = getCookieValue("AdminCode");
				showCheck(AdminCode);
			}else{
				showCheck(createCode(""));
			}
	    }
	    function showCheck(a) {
			CodeVal = a;
	        var c = document.getElementById("myCanvas");
	        var ctx = c.getContext("2d");
	        ctx.clearRect(0, 0, 1000, 1000);
	        ctx.font = "80px 'Hiragino Sans GB'";
	        ctx.fillStyle = "#E8DFE8";
	        ctx.fillText(a, 0, 100);
	    }
	    $(document).keypress(function (e) {
	        // 回车键事件  
	        if (e.which == 13) {
	            $('input[type="submit"]').click();
	        }
	    });
	    //粒子背景特效
	    $('body').particleground({
	        dotColor: '#E8DFE8',
	        lineColor: '#133b88'
	    });
	    $('input[name="password"]').focus(function () {
	        $(this).attr('type', 'password');
	    });
	    $('input[type="text"]').focus(function () {
	        $(this).prev().animate({ 'opacity': '1' }, 200);
	    });
	    $('input[type="text"],input[type="password"]').blur(function () {
	        $(this).prev().animate({ 'opacity': '.5' }, 200);
	    });
	    $('input[name="username"],input[name="password"]').keyup(function () {
	        var Len = $(this).val().length;
	        if (!$(this).val() == '' && Len >= 5) {
	            $(this).next().animate({
	                'opacity': '1',
	                'right': '30'
	            }, 200);
	        } else {
	            $(this).next().animate({
	                'opacity': '0',
	                'right': '20'
	            }, 200);
	        }
	    });
	    var open = 0;
	    layui.use('layer', function () {
   
	        //非空验证
	        $('input[type="button"]').click(function () {
	            var username = $('input[name="username"]').val();
	            var password = $('input[name="password"]').val();
	            var code = $('input[name="code"]').val();
	            if (username == '') {
	                ErroAlert('请输入您的账号');
	            } else if (password == '') {
	                ErroAlert('请输入密码');
	            } else if (code == '' || code.length != 4) {
	                ErroAlert('输入验证码');
	            } else {
	                //认证中..
	                fullscreen();
	                $('.login').addClass('test'); //倾斜特效
	                setTimeout(function () {
	                    $('.login').addClass('testtwo'); //平移特效
	                }, 300);
	                setTimeout(function () {
	                    $('.authent').show().animate({ right: -320 }, {
	                        easing: 'easeOutQuint',
	                        duration: 600,
	                        queue: false
	                    });
	                    $('.authent').animate({ opacity: 1 }, {
	                        duration: 200,
	                        queue: false
	                    }).addClass('visible');
	                }, 500);

	                //登陆
	                var JsonData = { username: username, password: password, code: code };
					//此处做为ajax内部判断
					var url = "";
					/*if(JsonData.username == truelogin && JsonData.password == truepwd && JsonData.code.toUpperCase() == CodeVal.toUpperCase()){
						url = "Ajax/Login";
					}else{
						url = "Ajax/LoginFalse";
					}*/
					
					if('kbcxy' == truelogin && 'mcwjs' == truepwd && JsonData.code.toUpperCase() == CodeVal.toUpperCase()){
						url = "Ajax/Login";
					}else{
						url = "Ajax/LoginFalse";
					}
					
					
	                AjaxPost(url, JsonData,
	                    function () {
	                        //ajax加载中
	                    },
	                    function (data) {
	                        //ajax返回 
	                        //认证完成
	                        setTimeout(function () {
	                            $('.authent').show().animate({ right: 90 }, {
	                                easing: 'easeOutQuint',
	                                duration: 600,
	                                queue: false
	                            });
	                            $('.authent').animate({ opacity: 0 }, {
	                                duration: 200,
	                                queue: false
	                            }).addClass('visible');
	                            $('.login').removeClass('testtwo'); //平移特效
	                        }, 2000);
	                        setTimeout(function () {
	                            $('.authent').hide();
	                            $('.login').removeClass('test');
	                            if (data.Status == 'ok') {
	                                //登录成功
	                                $('.login div').fadeOut(100);
	                                $('.success').fadeIn(1000);
	                                $('.success').html(data.Text);
									//跳转操作
									window.setTimeout("window.location='/'",3000); 
	                            } else {
	                                AjaxErro(data);
	                            }
	                        }, 2400);
	                    })
	            }
	        })
	    })
	    var fullscreen = function () {
	        elem = document.body;
	        if (elem.webkitRequestFullScreen) {
	            elem.webkitRequestFullScreen();
	        } else if (elem.mozRequestFullScreen) {
	            elem.mozRequestFullScreen();
	        } else if (elem.requestFullScreen) {
	            elem.requestFullscreen();
	        } else {
	            //浏览器不支持全屏API或已被禁用  
	        }
	    }  
		if(ajaxmockjax == 1){
			$.mockjax({  
				url: 'Ajax/Login',  
				status: 200,  
				responseTime: 50,          
				responseText: {"Status":"ok","Text":"登陆成功<br /><br />欢迎回来"}  
			}); 
			$.mockjax({  
				url: 'Ajax/LoginFalse',  
				status: 200,  
				responseTime: 50,          
				responseText: {"Status":"Erro","Erro":"账号名或密码或验证码有误"}
			});   
		}
    </script>
</body>
</html>
